/*
 * @Author: silence silence9685@163.com
 * @Date: 2023-06-13 15:50:53
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-10-26 13:27:43
 * @FilePath: \ems_neutral_app\lib\common\Method\CommonMethod.dart
 * @Description: 公共方法
 */

import 'package:ems_neutral_app/pages/Mine/Language/SilLocalizations/SilLocalizations.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../pages/Mine/Language/LanguageController.dart';
import '../../utils/router/ARouter.dart';
import '../module/WebViewPage/WebViewPage.dart';

/**服务条款*/
gotoServerTocolPage(BuildContext context) {
  String url = '';
  LanguageController _languageController =
      Get.put<LanguageController>(LanguageController());
  bool isPromptEnglish = _languageController.isPromptEnglish();

  if (isPromptEnglish) {
    url = "https://privacy.epcchance.com/privacy.html";
  } else {
    url = "https://privacy.epcchance.com/yhxy.html";
  }

  ARoute.gotoPage(
      context,
      WebViewPage(
        url,
        title: LangOf(context)?.aboutUs?.service,
      ));
}

/**隐私协议页面*/
gotoProTocolPrivacyPage(BuildContext context) {
  String url = '';
  LanguageController _languageController =
      Get.put<LanguageController>(LanguageController());
  bool isPromptEnglish = _languageController.isPromptEnglish();
  if (isPromptEnglish) {
    url = "https://privacy.epcchance.com/privacy.html";
  } else {
    url = "https://privacy.epcchance.com/yhxy.html";
  }

  ARoute.gotoPage(
      context,
      WebViewPage(
        url,
        title: LangOf(context)?.aboutUs?.service,
      ));
}

/// 导航到其他页面
// navToPage(Widget page) {
//   ARoute.gotoPage(navigatorKey.currentState!.context, page);
// }

/**
 * 退出键事件
 */
void globalTextFieldDismiss(BuildContext context) {
  FocusScopeNode currentFocus = FocusScope.of(context);
  if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
    FocusManager.instance.primaryFocus!.unfocus();
  }
}
